//package cn.tedu.library.service.realm;
//
//import cn.tedu.library.bean.Manager;
//import cn.tedu.library.service.ManagerService;
//import org.apache.shiro.authc.*;
//import org.apache.shiro.authc.credential.CredentialsMatcher;
//import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
//import org.apache.shiro.authz.AuthorizationInfo;
//import org.apache.shiro.realm.AuthorizingRealm;
//import org.apache.shiro.subject.PrincipalCollection;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//@Service
//public class ShiroUserRealm extends AuthorizingRealm {
//    @Autowired
//    private ManagerService managerService;
//    @Override
//    public CredentialsMatcher getCredentialsMatcher() {
//        //1，构建加密对象并指定算法
//        HashedCredentialsMatcher cMatcher=new HashedCredentialsMatcher("MD5");
//        //2.设置加密次数
//        cMatcher.setHashIterations(0);
//        return cMatcher;
//    }
//    @Override
//    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
//        UsernamePasswordToken uToken=(UsernamePasswordToken)token;
//        String username=uToken.getUsername();
//        Manager manager=managerService.selectByManager(username);
//        SimpleAuthenticationInfo info =
//                new SimpleAuthenticationInfo(manager,manager.getPWD(),getName());
//        return info;
//}
//
//    @Override
//    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
//
//
//        return null;
//    }
//}
